#!/bin/sh
#join kernel file(uImage) and file system (radisk...) to be one flash file..

DES_DIR=~/tftpboot/
FLASH_TARGET_IMGE=flash_image
UIMAGE_NALE=~/tftpboot/uImage
FILESYS_NAME=~/tftpboot/ramdisk_ist_3.0.x.gz

rm -f $FLASH_TARGET_IMGE

if [ -e $UIMAGE_NALE ]; then
#3M space for uImage
	dd of=$FLASH_TARGET_IMGE bs=1k count=3072 if=/dev/zero
	dd of=$FLASH_TARGET_IMGE bs=1k conv=notrunc if=$UIMAGE_NALE
else
	echo "Error: no found $UIMAGE_NALE"
	echo "Please check it"
	exit 1
fi

if [ -e $FILESYS_NAME ]; then
	echo "Appending file system...."
	cat $FILESYS_NAME >> $FLASH_TARGET_IMGE
else
	echo "Error: no found $FILESYS_NAME"
	echo "Please check it"
	rm -rf $FLASH_TARGET_IMGE
	exit 1
fi
echo "#####Installing to $DES_DIR"
	mv -f $FLASH_TARGET_IMGE $DES_DIR
	ls -al $DES_DIR
echo "#####Finished!"



